import {http as api} from "slash-admin";
import {ApiResponse, ListResponse} from "slash-admin";
import {PageQueryParam, SearchKeyQueryParam} from "slash-admin";


export interface AuthTbUserLoginLogResponse {
        id:string,
        loginName:string,
        loginIp:string,
        loginMsg:string,
        fkUserId:string,
        loginBrowser:string,
        loginOs:string,
        loginSource:string,
        loginOutTime:string,
        loginDuration:string,
        sessionKey:string,
        createTime:string,
        updateTime:string,
        createUserAccount:string,
        updateUserAccount:string,
    }
export interface SelectAuthTbUserLoginLogPageListQueryParam extends SearchKeyQueryParam {

}

/**
 * 分页查询列表
 * @param query
 */
export const selectPageList = (query: SelectAuthTbUserLoginLogPageListQueryParam): Promise<ListResponse<AuthTbUserLoginLogResponse>> => {
    return api.doGet('/AuthApp/AuthTbUserLoginLog/selectPageList', query)
}
/**
 * 分页查询当前用户的日志列表
 */
export const selectPageListByUser = (query: SelectAuthTbUserLoginLogPageListQueryParam): Promise<ListResponse<AuthTbUserLoginLogResponse>> => {
    return api.doGet('/AuthApp/AuthTbUserLoginLog/selectCurrentUserPageList', query)
}
/**
 * 根据ID查询
 * @param id
 */
export const selectById = (id: string|number): Promise<ApiResponse<AuthTbUserLoginLogResponse>> => {
    return api.doGet('/AuthApp/AuthTbUserLoginLog/selectById', {id: id})
}


/**
 * 新增
 * @param data
 */
export const doSaveEntity = (data: any): Promise<ApiResponse<boolean>> => {
    return api.doPost('/AuthApp/AuthTbUserLoginLog/save', data)
}
/**
 * 实体
 * @param data
 */
export const doUpdateEntity = (data: any): Promise<ApiResponse<boolean>> => {
    return api.doPost('/AuthApp/AuthTbUserLoginLog/update', data)
}
/**
 * 逻辑删除
 * @param id|ids
 */
export const doLogicDeleteEntity = (ids: Array<string | number> | number | string): Promise<ApiResponse<boolean>> => {
    let data:any = null;
    if (Array.isArray(ids)) {
        data = ids;
    } else {
        data = [ids];
    }
    return api.doPost('/AuthApp/AuthTbUserLoginLog/logicDelete', data)
}
/**
 * 物理删除
 * @param id|ids
 */
export const doDeleteEntity = (ids: Array<string> | number | string): Promise<ApiResponse<boolean>> => {
    let data:any = null;
    if (Array.isArray(ids)) {
        data = ids;
    } else {
        data = [ids];
    }
    return api.doPost('/AuthApp/AuthTbUserLoginLog/delete', data)
}

export default {
    selectPageList,
    selectById,
    doDeleteEntity,
    doLogicDeleteEntity,
    doUpdateEntity,
    doSaveEntity,
    selectPageListByUser
}
